﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NullLoggingServiceTests.cs" company="XamlNinja">
//   2011 Richard Griffin and Ollie Riches
// </copyright>
// <summary>
//   Null logger tests - we follow BDD principles, http://dannorth.net/introducing-bdd/
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WP7Contrib.Logging.Tests
{
    using System;
    using Logging;
    using Microsoft.Silverlight.Testing;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class NullLoggingServiceTests : SilverlightTest
    {
        [TestMethod]
        public void ShouldCreatedAnInstanceWithoutSideAffects()
        {
            // Given and When we create an instance of the NullLoggingService provider...
            var cacheProvider = new NullLoggingService();

            // Then we don't expect any side effect to be generated...
            Assert.IsNotNull(cacheProvider);
        }

        [TestMethod]
        public void ShouldWriteSimpleMessageWithoutSideAffects()
        {
            // Given we can create an instance...
            var logger = new NullLoggingService();

            // When we write a simple message...
            logger.Write("The answer is 42!");

            // Then we don't expect any exceptions...
        }

        [TestMethod]
        public void ShouldWriteComplexMessageWithoutSideAffects()
        {
            // Given we can create an instance...
            var logger = new NullLoggingService();

            // When we write a complex message...
            logger.Write("The answer is 42!", 12, 12);

            // Then we don't expect any exceptions...
        }

        [TestMethod]
        public void ShouldWriteSimpleMessageAndExceptionWithoutSideAffects()
        {
            // Given we can create an instance...
            var logger = new NullLoggingService();

            // When we write a simple message and exception...
            logger.Write("The answer is 42!", new Exception("My Exception!"));

            // Then we don't expect any exceptions...
        }

        [TestMethod]
        public void ShouldWriteDiagnosticsWithoutSideAffects()
        {
            // Given we can create an instance...
            var logger = new NullLoggingService();

            // When we write diagnostics message...
            logger.WriteDiagnostics();

            // Then we don't expect any exceptions...
        }

        [TestMethod]
        public void ShouldClearWithoutSideAffects()
        {
            // Given we can create an instance...
            var logger = new NullLoggingService();

            // When we clear the log...
            logger.Clear();

            // Then we don't expect any exceptions...
        }

        [TestMethod]
        public void ShouldEnableWithoutSideAffects()
        {
            // Given we can create an instance...
            var logger = new NullLoggingService();

            // When we enable the logging service...
            logger.Enable();

            // Then we don't expect any exceptions...
        }

        [TestMethod]
        public void ShouldDisableWithoutSideAffects()
        {
            // Given we can create an instance...
            var logger = new NullLoggingService();

            // When we disable the logging service...
            logger.Disable();

            // Then we don't expect any exceptions...
        }
    }
}
